public class Demo19 {
    public static void main(String[] args) {
        // 必须对同一个对象进行等待唤醒
        Object object = new Object();

        Thread t1 = new Thread(()->{
            synchronized (object){
                System.out.println("wait开始!");
                try {
                    object.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("wait结束!");
            }
        });

        Thread t2 = new Thread(()->{
            synchronized (object){
                try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }

            object.notify();
            System.out.println("wait唤醒!");
            }
        });

        t1.start();
        t2.start();
    }
}
